package com.aaa.controller;

import com.aaa.entity.Product;
import com.aaa.service.ProductService;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;
    @Value("${student.name}")
    private String name;

    @RequestMapping("name")
    public String getName(){
        return name;
    }
    @RequestMapping("/get/{pid}")
    @SentinelResource(value = "hot") // 如果使用热点参数，默认对SpringMVC无效，所以使用
    public Product getShopInfo(@PathVariable Long pid){
        return productService.getShopInfo(pid);
    }

    @GetMapping("/queryOrder")
    public String queryOrder(Long pid){
        productService.getShopInfo(pid);
        return "查询订单";
    }
    @GetMapping("/addOrder")
    public String addOrder(Long pid){
        productService.getShopInfo(pid);
        return "添加订单";
    }


    @GetMapping("/write")
    public String write(){
        return "写业务";
    }
    @GetMapping("/read")
    public String read(){
        return "读业务";
    }
}
